/**
 * 从地址栏传值的代码
 * @param param
 * @returns
 */

function getParameter(param){
	var query = window.location.search;
	var iLen = param.length;
	var iStart = query.indexOf(param);
	if (iStart == -1)
		return "";
	iStart += iLen + 1;
	var iEnd = query.indexOf("&", iStart);
	if (iEnd == -1)
		return query.substring(iStart);
	return query.substring(iStart, iEnd);
} 

$(function(){
	if(getParameter("man")==1){
		$("#department").val("财务部门")
	}else{
		$("#department").val("总经理")
	}
	
})

layui.use('form', function(){
        var form = layui.form; 


        form.render();
 });
 layui.use(['form', 'layedit', 'laydate'], function(){
	  var form = layui.form
	  ,laydate = layui.laydate
	  ,layer = layui.layer
	  ,layedit = layui.layedit;
 
		$("#sub").click(function(){
			if($("#audit").val()==""){
				layer.msg('未做审核操作', {icon: 2}); 
			}else if($("#auditCause").val()==""){
				layer.msg('审核意见不能为空', {icon: 2}); 
			}else{
				var url = "../../listenAuditing/addProductionAuditing.action";
				var date = {"vocationalWorkId":getParameter("prodId"),"auditingDepartment":$("#department").val(),"auditingOrder":$("#order").val(),"auditingStatus":$("#audit").val(),"auditingExplain":$("#auditCause").val(),"man":getParameter("man")};
				$.post(url,date,function(mes){
					if(mes>0){
  					  window.parent.location.reload()
  					  var index=parent.layer.getFrameIndex(window.name);
  					  parent.layer.close(index);
  				  }
				},"json")
			}
		})	  
});